﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Web.Shared
{
    public partial class InitSystemUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUserCollection users = Membership.GetAllUsers();
            // Membership.DeleteUser("panbbb");
            if (users.Count > 0)
            {
                Response.Redirect("AdminLogin.aspx");
            }
        }
        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            MembershipUserCollection users = Membership.GetAllUsers();
            if (users.Count == 1)
            {
                foreach (MembershipUser user in users)
                {
                    Roles.CreateRole("Administrators");
                    Roles.CreateRole("Admins");
                    Roles.CreateRole("Corps");
                    Roles.CreateRole("Users");
                    Roles.AddUserToRoles(user.UserName, new string[] {
                            "Administrators",
                            "Admins",
                            "Corps",
                            "Users"});
                }
            }
        }
    }
}
